package com.googlecode.imanager.client.form;

import com.googlecode.imanager.client.Container;
import com.googlecode.imanager.client.bridge.form.ITextArea;
import com.googlecode.imanager.client.util.Utils;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class TextArea extends InputText implements ITextArea {

    private static final long serialVersionUID = 1L;
    
    private WrapMode wrapMode;
    // TODO ScrollMode 
    private ScrollMode scrollMode;
    private Boolean wantTabKeys;

    public TextArea() {
        wrapMode = WrapMode.DEFAULT;
        wantTabKeys = false;
    }

    public TextArea(Container parent) {
        this();
        setParent(parent);
    }

    public void setWantTabKeys(Boolean wantTabKeys) {
        if (!Utils.isEquals(this.wantTabKeys, wantTabKeys)){
            this.wantTabKeys = wantTabKeys;
            getBridge().setWantTabKeys(wantTabKeys);
        }
    }

    public Boolean getWantTabKeys() {
        return wantTabKeys;
    }

    public boolean isWantTabKeys() {
        return wantTabKeys == null ? false : wantTabKeys;
    }

    public WrapMode getWrapMode() {
        return wrapMode;
    }

    public void setWrapMode(WrapMode wrapMode) {
        if (wrapMode == null){
            wrapMode = WrapMode.DEFAULT;
        }
        if (this.wrapMode != wrapMode){
            this.wrapMode = wrapMode;
            getBridge().setWrapMode(wrapMode);
        }
    }

    @Override
    public TextArea clone() {
        return (TextArea) super.clone();
    }

    @Override
    protected ITextArea getBridge() {
        return (ITextArea) lookupBridge();
    }

}
